<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>通告管理</title>
<link type="text/css" rel="stylesheet"
	href="${ pageContext.request.contextPath }/resources/csses/not_leave_.css">
<link type="text/css" rel="stylesheet"
	href="${ pageContext.request.contextPath }/resources/csses/notif.css">

<script type="text/javascript"
	src="${ pageContext.request.contextPath }/resources/script/jquery-3.1.1.js"></script>
<script type="text/javascript"
	src="${ pageContext.request.contextPath }/resources/script/layer-v3.0.1/layer/layer.js"></script>
<script type="text/javascript">
	$(document)
			.ready(
					function() {
						//通过jquery类选择器设置点击事件
						$(".delete")
								.click(
										function() {
											var nid = $(this).parent().parent()
													.attr('id');
											//layer.msg(nid);
											layer
													.confirm(
															'是否要删除这条通知？',
															{
																btn : [ '确定',
																		'取消' ]
															},
															function() {
																window.location.href = "${ pageContext.request.contextPath}/${ roler }/deletenotification?nId="
																		+ nid
																		+ "&currentPage="
																		+ "${ currentPage }"
																;
																//layer.msg(nid);
															}, function() {
																//layer.msg('执行取消的代码！');
															});
										});
						$(".edit")
								.click(
										function() {
											var nid = $(this).parent().parent()
													.attr('id');
											window.location.href = "${ pageContext.request.contextPath}/${ roler }/editnotification?nId="
													+ nid;
										});
					});
</script>
</head>
<body>
	<div id="containertitle">
		已发通知
		<div style="float: right;">
			<a id="new" style="text-align: right;"
				href="${ pageContext.request.contextPath }/${ roler }/addnotification">新发通知</a>
		</div>
	</div>

	<table id="notification" class="manager">
		<thead id="notificationtr" class="managerthead">
			<tr>
				<td class="head">&nbsp;</td>
				<th>主题</th>
				<td class="time">发帖时间</td>
				<td></td>
				<td></td>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${ notifications }" var="notification"
				varStatus="statu">
				<tr id="${ notification.id }">
					<td class="cell"><c:out value=" ${ statu.index+1 }" /></td>
					<td class="cell" style="padding-left: 20px; text-align: left;"><a
						class="notification"
						href="${ pageContext.request.contextPath }/notification?nId=${ notification.id }">
							<c:out value="${ notification.title }" />
							<c:if test="${notification.toped }">
								<div style="display: inline; color: red;">top</div>
							</c:if>
					</a></td>
					<td class="cell" align="center"><c:out
							value="${ notification.timestr }" /></td>
					<td class="cell" align="center" style="width: 30px;"><img
						class="edit" alt="Edit"
						src="${ pageContext.request.contextPath }/resources/images/edit.png"
						width="20px;" height="20px;"></td>
					<td class="cell" align="center" style="width: 30px;"><img
						class="delete" alt="Delete"
						src="${ pageContext.request.contextPath }/resources/images/Delete.png"
						width="20px;" height="20px;"></td>
				</tr>

			</c:forEach>
			<tr>
				<td style="text-align: center; font-size: 15px;" colspan="5"><a style="text-decoration: none; font-size: 12px;"
					href="${ pageContext.request.contextPath }/${ roler }/notification?current=${ currentPage > 1 ? currentPage - 1 : 1}"><<上一页&nbsp;&nbsp;</a>
					<c:choose>
						<c:when test="${ pagecount <= 5 }">
							<c:forEach begin="1" end="${ pagecount }" var="index" step="1">
								<c:choose>
									<c:when test="${ index == currentPage }">
										<a style="color: red;"><c:out value="${ index }" /> </a>
									</c:when>
									<c:otherwise>
										<a style="text-decoration: none;"
											href="${ pageContext.request.contextPath }/${ roler }/notification?current=${ index}"><c:out
												value="${ index }" /> </a>
									</c:otherwise>
								</c:choose>
							</c:forEach>
						</c:when>
						<c:when test="${ currentPage > pagecount - 2 }">
							<c:forEach begin="${ pagecount - 4 }" end="${ pagecount }"
								step="1" var="index">
								<c:choose>
									<c:when test="${ index == currentPage }">
										<a style="color: red;"><c:out value="${ index }" /> </a>
									</c:when>
									<c:otherwise>
										<a style="text-decoration: none;"
											href="${ pageContext.request.contextPath }/${ roler }/notification?current=${ index}"><c:out
												value="${ index }" /> </a>
									</c:otherwise>
								</c:choose>
							</c:forEach>
						</c:when>
						<c:otherwise>
							<c:choose>
								<c:when test="${ currentPage > 3 }">
									<c:forEach begin="${ currentPage - 2 }"
										end="${ currentPage + 2 > pagecount ? pagecount : currentPage + 2}"
										step="1" var="index">
										<c:choose>
											<c:when test="${ index == currentPage }">
												<a style="color: red;"><c:out value="${ index }" /> </a>
											</c:when>
											<c:otherwise>
												<a style="text-decoration: none;"
													href="${ pageContext.request.contextPath }/${ roler }/notification?current=${ index}"><c:out
														value="${ index }" /> </a>
											</c:otherwise>
										</c:choose>
									</c:forEach>
								</c:when>
								<c:otherwise>
									<c:forEach begin="1" end="${ pagecount < 5 ? pagecount : 5 }"
										var="index" step="1">
										<c:choose>
											<c:when test="${ index == currentPage }">
												<a style="color: red;"><c:out value="${ index }" /> </a>
											</c:when>
											<c:otherwise>
												<a style="text-decoration: none;"
													href="${ pageContext.request.contextPath }/${ roler }/notification?current=${ index}"><c:out
														value="${ index }" /> </a>
											</c:otherwise>
										</c:choose>
									</c:forEach>
								</c:otherwise>
							</c:choose>
						</c:otherwise>
					</c:choose> <a style="text-decoration: none; font-size: 12px;"
					href="${ pageContext.request.contextPath }/${ roler }/notification?current=${ currentPage < pagecount ? currentPage + 1 : pagecount}">&nbsp;&nbsp;下一页>></a></td>
			</tr>
		</tbody>
	</table>
</body>
</html>